package cn.tedu.evilboot.controller;

import cn.tedu.evilboot.mapper.DynamicMapper;
import cn.tedu.evilboot.pojo.dto.DynamicDTO;
import cn.tedu.evilboot.pojo.entity.Dynamic;
import cn.tedu.evilboot.pojo.vo.DynamicVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/evil/dynamic")
public class DynamicController {

    @Autowired(required = false)
    DynamicMapper mapper;

@RequestMapping("/select")
    public List<DynamicVO>  select(){
    return mapper.select();
    }
@RequestMapping("/selectContent")
    public Dynamic selectContent(int id){
    return mapper.selectContent(id);
}
@RequestMapping("/post")
    public void insert(@RequestBody DynamicDTO dto){
    DynamicDTO d= new DynamicDTO();
    BeanUtils.copyProperties(dto,d);
    System.out.println("dto = " + d);
    mapper.insert(d);
}
}
